#!/bin/bash

ct=/usr/atria/bin/cleartool

DO=$1
PATTERN=$2
IND=$3
EXTDO=$($ct des -fmt "%n\n" $DO)
SUBDOS=$($ct catcr $DO | grep -E '@@[-0-9]+' | grep -v $EXTDO)

if [ -n "$SUBDOS" ]; then
  for cr in $SUBDOS; do
    pat="$($ct catcr -flat $cr | grep $PATTERN)"
    if [ -n "$pat" ]
      then
        echo "${IND}$cr:"
        $0 $cr $PATTERN "$IND  "
    fi
  done
fi
